/**
 * \file mode_freq.c
 * \brief Mode de commande fréquence.
 * \author Nicolas M.
 * \version 0.2
 * \date 20 mars 2011
 *
 *
 */

#include "mode_freq.h"

#include "../control/ctrl_freq.h"
#include "../control/ctrl_vol.h"

#include "../utils/utils.h"
#include <msp430x14x.h>
#include <stdlib.h>
#include <stdio.h>

char freqTxtBuffer[16];

void freqButton2fct()
{
	augmenterFrequence();
	remettreSon(); // Evite le pb de conflit avec le bargraph
}

void freqButton3fct()
{
	diminuerFrequence();
	remettreSon(); // Evite le pb de conflit avec le bargraph
}

void activateFreqMode()
{
	restaurerFrequence(getFrequence());
}

char *getFreqText()
{
	char *chaine, *substr,nb[4];
	int freq, unite, virgule;
	chaine = freqTxtBuffer;

	freq = getFrequence();
	unite = freq/10;
	itoa(unite,nb,10);
	
	sprintf(chaine , nb);
	chaine = strcat(chaine, ".");

	virgule = freq - unite*10;
	itoa(virgule,nb,10);
	chaine = strcat(chaine, nb);

	chaine = strcat(chaine, "Mhz");

	
	return chaine;
}
